<?php

namespace app\api\logic;

use GuzzleHttp\Client;
use think\facade\Log;


class UserLogic extends BaseSDKLogic
{
    // 根据authCode获取用户信息
    public function userInfo($code)
    {
        $configDing = \think\facade\Config::get('ding');

        // 创建客户端请求
        $client = new Client();
        // 请求选项
        $response = $client->request('POST',$configDing['host_old'].'/topapi/v2/user/getuserinfo',[
            'headers' => [
                'Content-Type' => 'application/json',
            ],
//            'verify' => false,
            'json' => ['code' => $code],
            'query' => ['access_token' => $this->accessToken()],

        ]);


        Log::write([
            'code' => $code,
            'access_token' => $this->accessToken()
        ],'myLog');



        $body = $response->getBody();
        $stringBody = (string) $body;

        Log::write(json_decode($stringBody,true),'myLog');
        return json_decode($stringBody,true);

    }


//    public function

}